home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 015 / hpfilter.arc / HPFILTER.ASM < prev    next >
Assembly Source File  |  1987-01-18  |  18KB  |  602 lines

  1.  
  2. ;**********************************************************************************
  3. ;* This program traps the printer output interrupt (17H), and translates
  4. ;* outgoing IBM-style line drawing characters to codes compatible with the
  5. ;* HP Laserjet.
  6. ;*                                          *
  7. ;*                                          *
  8. ;* USE:  Giving the command "HPFILTER" for the first time will install the           *
  9. ;* conversion utility, and report "HPFilter installed and running."                  *
  10. ;* Thereafter, giving the "HPFILTER" command will toggle the translation             *
  11. ;* feature off and on, reporting "HPFilter temporarily deactivated" or               *
  12. ;* "HPFilter reactivated."                                                           *
  13. ;*                                          *
  14. ;**********************************************************************************
  15.  
  16. CSEG    segment para public 'CODE'
  17.     assume    cs:CSEG, ds:CSEG
  18.  
  19. DOS    macro    fcn_code, location_arg
  20.     mov    ah, fcn_code
  21.     ifnb    <location_arg>
  22.     mov    dx, offset location_arg
  23.     endif
  24.     int    21H
  25.     endm
  26.  
  27.  
  28. ; The printer interrupt number is 17H.
  29.  
  30. PRINTER_INTERRUPT    equ    17H
  31. SIGNATURE        equ    0d6f1H    ;not opcodes
  32. ESC            equ    1bH
  33.  
  34. PRINT_MESSAGE        equ    09H
  35. SET_VECTOR        equ    25H
  36.  
  37.  
  38.     org    100H            ; goes thru EXE2BIN
  39.  
  40. HOME:    jmp    START            ; skip around all the data space
  41.  
  42.  
  43. ; Data areas
  44.  
  45. BIOS_HANDLER   dd      ?           ; address of former int handler
  46.  
  47. IN_CHAR        dw      ?
  48. C_STRING       DW      0           ;CONTROL STRING IN PROGRESS
  49. BOLD_ON        DB      0           ;DO BOLD FACE
  50. ;=========================================================================
  51. ;  This table contains the base address for the character strings that
  52. ;  will define the graphic characters.
  53. ;=========================================================================
  54. HP_BASE        equ     this byte
  55.        dw      offset hpc179
  56.        dw      offset hpc180
  57.        dw      offset hpc181
  58.        dw      offset hpc182
  59.        dw      offset hpc183
  60.        dw      offset hpc184
  61.        dw      offset hpc185
  62.        dw      offset hpc186
  63.        dw      offset hpc187
  64.        dw      offset hpc188
  65.        dw      offset hpc189
  66.        dw      offset hpc190
  67.        dw      offset hpc191
  68.        dw      offset hpc192
  69.        dw      offset hpc193
  70.        dw      offset hpc194
  71.        dw      offset hpc195
  72.        dw      offset hpc196
  73.        dw      offset hpc197
  74.        dw      offset hpc198
  75.        dw      offset hpc199
  76.        dw      offset hpc200
  77.        dw      offset hpc201
  78.        dw      offset hpc202
  79.        dw      offset hpc203
  80.        dw      offset hpc204
  81.        dw      offset hpc205
  82.        dw      offset hpc206
  83.        dw      offset hpc207
  84.        dw      offset hpc208
  85.        dw      offset hpc209
  86.        dw      offset hpc210
  87.        dw      offset hpc211
  88.        dw      offset hpc212
  89.        dw      offset hpc213
  90.        dw      offset hpc214
  91.        dw      offset hpc215
  92.        dw      offset hpc216
  93.        dw      offset hpc217
  94.        dw      offset hpc218
  95.        dw      offset hpc219
  96.        dw      offset hpc220
  97.        dw      offset hpc221
  98.        dw      offset hpc222
  99.        dw      offset hpc223
  100.  
  101. ;=========================================================================
  102. ;  These strings are definitions for the PC graphic characters as they
  103. ;  are printed on the HP LazerJet + with out a ROM cartridge. They are
  104. ;  layed out on a 30x50 grid with the entry at 0,36 and extit at 31,36.
  105. ;  This corresponds to the character figure given in the tech manual.
  106. ;  Each line segment is 5 dots wide.
  107. ;
  108. ;  The periods '.' in the data below are to assist in alignment, they
  109. ;  are ignored for output, and may be removed
  110. ;=========================================================================
  111.  
  112. ESC    equ  27
  113. ;  │
  114. hpc179    db  ESC,"*p+14x-36Y.*c3a50bP"
  115.     db  ESC,"*p+16x+36Y",0
  116. ;  ┤
  117. hpc180    db  ESC,"*p+14x-36Y.*c3a50bP"
  118.     db  ESC,"*p-14x+20Y.*c17a3bP"
  119.     db  ESC,"*p+30x+16Y",0
  120. ;  ╡
  121. hpc181    db  ESC,"*p+14x-36Y.*c3a50bP"
  122.     db  ESC,"*p-14x+15Y.*c17a3bP"
  123.     db  ESC,"*p+10Y.....*c17a3bP"
  124.     db  ESC,"*p+30x+11Y",0
  125. ;  ╢
  126. hpc182    db  ESC,"*p+9x-36Y..*c3a50bP"
  127.     db  ESC,"*p+10X.....*c3a50bP"
  128.     db  ESC,"*p-19x+20Y.*c9a3bP"
  129.     db  ESC,"*p+30x+16Y",0
  130. ;  ╖
  131. hpc183    db  ESC,"*p-16Y.....*c22a3bP"
  132.     db  ESC,"*p+9X......*c3a30bP"
  133.     db  ESC,"*p+10X.....*c3a30bP"
  134.     db  ESC,"*p+11x+16Y",0
  135. ;  ╕
  136. hpc184    db  ESC,"*p+14x-21Y.*c3a35bP"
  137.     db  ESC,"*p-14X.....*c14a3bP"
  138.     db  ESC,"*p+10Y.....*c14a3bP"
  139.     db  ESC,"*p+30x+11Y",0
  140. ;  ╣
  141. hpc185    db  ESC,"*p+9x-36Y..*c3a18bP"
  142.     db  ESC,"*p+25Y.....*c3a25bP"
  143.     db  ESC,"*p-9x-10Y..*c12a3bP"
  144.     db  ESC,"*p+10Y.....*c12a3bP"
  145.     db  ESC,"*p+19x-25Y.*c3a50bP"
  146.     db  ESC,"*p+11x+36Y",0
  147. ;  ║
  148. hpc186    db  ESC,"*p+9x-36Y..*c3a50bP"
  149.     db  ESC,"*p+10x.....*c3a50bP"
  150.     db  ESC,"*p+11x+36Y",0
  151. ;  ╗
  152. hpc187    db  ESC,"*p-11Y.....*c12a3bP"
  153.     db  ESC,"*p+9X......*c3a25bP"
  154.     db  ESC,"*p-9x-10Y..*c22a3bP"
  155.     db  ESC,"*p+19X.....*c3a35bP"
  156.     db  ESC,"*p+11x+21Y",0
  157. ;  ╝
  158. hpc188    db  ESC,"*p+9x-36Y..*c3a18bP"
  159.     db  ESC,"*p-9x+15Y..*c9a3bP"
  160.     db  ESC,"*p+19x-15Y.*c3a28bP"
  161.     db  ESC,"*p-19x+25Y.*c19a3bP"
  162.     db  ESC,"*p+30x+11Y",0
  163. ;  ╜
  164. hpc189    db  ESC,"*p-16Y.....*c22a3bP"
  165.     db  ESC,"*p+9x-20Y..*c3a20bP"
  166.     db  ESC,"*p+10X.....*c3a20bP"
  167.     db  ESC,"*p+11x+36Y",0
  168. ;  ╛
  169. hpc190    db  ESC,"*p+14x-36Y.*c3a28bP"
  170.     db  ESC,"*p-14x+15Y.*c14a3bP"
  171.     db  ESC,"*p+10Y.....*c14a3bP"
  172.     db  ESC,"*p+30x+11Y",0
  173. ;  ┐
  174. hpc191    db  ESC,"*p-16Y.....*c14a3bP"
  175.     db  ESC,"*p+14X.....*c3a30bP"
  176.     db  ESC,"*p+16x+16Y",0
  177. ;  └
  178. hpc192    db  ESC,"*p+14x-16Y.*c16a3bP"
  179.     db  ESC,"*p-20Y.....*c3a20bP"
  180.     db  ESC,"*p+16x+36Y",0
  181. ;  ┴
  182. hpc193    db  ESC,"*p-16Y.....*c30a3bP"
  183.     db  ESC,"*p+14x-20Y.*c3a20bP"
  184.     db  ESC,"*p+16x+36Y",0
  185. ;  ┬
  186. hpc194    db  ESC,"*p-16Y.....*c30a3bP"
  187.     db  ESC,"*p+14X.....*c3a30bP"
  188.     db  ESC,"*p+16x+16Y",0
  189. ;  ├
  190. hpc195    db  ESC,"*p+14x-36Y.*c3a50bP"
  191.     db  ESC,"*p+3x+20Y..*c13a3bP"
  192.     db  ESC,"*p+13x+16Y",0
  193. ;  ─
  194. hpc196    db  ESC,"*p-16Y.....*c30a3bP"
  195.     db  ESC,"*p+30x+16Y",0
  196. ;  ┼
  197. hpc197    db  ESC,"*p-16Y.....*c30a3bP"
  198.     db  ESC,"*p+14x-20Y.*c3a50bP"
  199.     db  ESC,"*p+16x+36Y",0
  200. ;  ╞
  201. hpc198    db  ESC,"*p+14x-36Y.*c3a50bP"
  202.     db  ESC,"*p+3x+15Y..*c13a3bP"
  203.     db  ESC,"*p+10Y.....*c13a3bP"
  204.     db  ESC,"*p+13x+11Y",0
  205. ;  ╟
  206. hpc199    db  ESC,"*p+9x-36Y..*c3a50bP"
  207.     db  ESC,"*p+10X.....*c3a50bP"
  208.     db  ESC,"*p+3x+20Y..*c8a3bP"
  209.     db  ESC,"*p+8x+16Y",0
  210. ;  ╚
  211. hpc200    db  ESC,"*p+9x-36Y..*c3a28bP"
  212.     db  ESC,"*p+10X.....*c3a18bP"
  213.     db  ESC,"*p+15Y.....*c11a3bP"
  214.     db  ESC,"*p-10x+10Y.*c21a3bP"
  215.     db  ESC,"*p+21x+11Y",0
  216. ;  ╔
  217. hpc201    db  ESC,"*p+9x-21Y..*c3a35bP"
  218.     db  "............*c21a3bP"
  219.     db  ESC,"*p+10x+10Y.*c3a25bP"
  220.     db  "............*c11a3bP"
  221.     db  ESC,"*p+11x+11Y",0
  222. ;  ╩
  223. hpc202    db  ESC,"*p-11Y.....*c30a3bP"
  224.     db  ESC,"*p-10Y.....*c9a3bP"
  225.     db  ESC,"*p+22X.....*c8a3bP"
  226.     db  ESC,"*p-13x-15Y.*c3a18bP"
  227.     db  ESC,"*p+10X.....*c3a18bP"
  228.     db  ESC,"*p+11x+36Y",0
  229. ;  ╦
  230. hpc203    db  ESC,"*p-21Y.....*c30a3bP"
  231.     db  ESC,"*p+10Y.....*c9a3bP"
  232.     db  ESC,"*p+19X.....*c11a3bP"
  233.     db  ESC,"*p-10X.....*c3a25bP"
  234.     db  ESC,"*p+10X.....*c3a25bP"
  235.     db  ESC,"*p+11x+11Y",0
  236. ;  ╠
  237. hpc204    db  ESC,"*p+9x-36Y..*c3a50bP"
  238.     db  ESC,"*p+10X.....*c3a19bP"
  239.     db  ESC,"*p+25Y.....*c3a25bP"
  240.     db  ESC,"*p-10Y.....*c11a3bP"
  241.     db  ESC,"*p+10Y.....*c11a3bP"
  242.     db  ESC,"*p+11x+11Y",0
  243. ;  ═
  244. hpc205    db  ESC,"*p-21Y.....*c30a3bP"
  245.     db  ESC,"*p+10Y.....*c30a3bP"
  246.     db  ESC,"*p+30x+11Y",0
  247. ;  ╬
  248. hpc206    db  ESC,"*p+9x-36Y..*c3a18bP"
  249.     db  ESC,"*p+25Y.....*c3a25bP"
  250.     db  ESC,"*p+10x-25Y.*c3a18bP"
  251.     db  ESC,"*p+25Y.....*c3a25bP"
  252.     db  ESC,"*p-19x-10Y.*c12a3bP"
  253.     db  ESC,"*p+19X.....*c11a3bP"
  254.     db  ESC,"*p-19x+10Y.*c12a3bP"
  255.     db  ESC,"*p+19X.....*c11a3bP"
  256.     db  ESC,"*p+11x+11Y",0
  257. ;  ╧
  258. hpc207    db  ESC,"*p-21Y.....*c30a3bP"
  259.     db  ESC,"*p+10Y.....*c30a3bP"
  260.     db  ESC,"*p+14x-25Y.*c3a15bP"
  261.     db  ESC,"*p+16x+36Y",0
  262. ;  ╨
  263. hpc208    db  ESC,"*p+9x-36Y..*c3a20bP"
  264.     db  ESC,"*p+10X.....*c3a20bP"
  265.     db  ESC,"*p-19x+20Y.*c30a3bP"
  266.     db  ESC,"*p+30x+16Y",0
  267. ;  ╤
  268. hpc209    db  ESC,"*p-21Y.....*c30a3bP"
  269.     db  ESC,"*p+10Y.....*c30a3bP"
  270.     db  ESC,"*p+14X.....*c3a25bP"
  271.     db  ESC,"*p+16x+11Y",0
  272. ;  ╥
  273. hpc210    db  ESC,"*p-16Y.....*c30a3bP"
  274.     db  ESC,"*p+9X......*c3a35bP"
  275.     db  ESC,"*p+10X.....*c3a35bP"
  276.     db  ESC,"*p+11x+16Y",0
  277. ;  ╙
  278. hpc211    db  ESC,"*p+9x-36Y..*c3a20bP"
  279.     db  ESC,"*p+10X.....*c3a20bP"
  280.     db  ESC,"*p-10x+20Y.*c21a3bP"
  281.     db  ESC,"*p+21x+16Y",0
  282. ;  ╘
  283. hpc212    db  ESC,"*p+14x-36Y.*c3a28bP"
  284.     db  ESC,"*p+15Y.....*c21a3bP"
  285.     db  ESC,"*p+10Y.....*c21a3bP"
  286.     db  ESC,"*p+16x+11Y",0
  287. ;  ╒
  288. hpc213    db  ESC,"*p+14x-21Y.*c3a35bP"
  289.     db  "............*c16a3bP"
  290.     db  ESC,"*p+10Y.....*c16a3bP"
  291.     db  ESC,"*p+16x+11Y",0
  292. ;  ╓
  293. hpc214    db  ESC,"*p+9x-16Y..*c3a35bP"
  294.     db  "............*c21a3bP"
  295.     db  ESC,"*p+10X.....*c3a35bP"
  296.     db  ESC,"*p+11x+16Y",0
  297. ;  ╫
  298. hpc215    db  ESC,"*p+9x-36Y..*c3a50bP"
  299.     db  ESC,"*p+10X.....*c3a50bP"
  300.     db  ESC,"*p-19x+20Y.*c30a3bP"
  301.     db  ESC,"*p+30x+16Y",0
  302. ;  ╪
  303. hpc216    db  ESC,"*p-21Y.....*c30a3bP"
  304.     db  ESC,"*p+10Y.....*c30a3bP"
  305.     db  ESC,"*p+14x-25Y.*c3a50bP"
  306.     db  ESC,"*p+16x+36Y",0
  307. ;  ┘
  308. hpc217    db  ESC,"*p-16Y.....*c14a3bP"
  309.     db  ESC,"*p+14x-20Y.*c3a23bP"
  310.     db  ESC,"*p+16x+36Y",0
  311. ;  ┌
  312. hpc218    db  ESC,"*p+14x-16Y.*c16a3bP"
  313.     db  "............*c3a30bP"
  314.     db  ESC,"*p+16x+16Y",0
  315. ;  █
  316. hpc219    db  ESC,"*p-36Y.....*c30a50bP"
  317.     db  ESC,"*p+30x+36Y",0
  318. ;  ▄
  319. hpc220    db  ESC,"*p-36Y.....*c30a25bP"
  320.     db  ESC,"*p+30x+36Y",0
  321. ;  ▌
  322. hpc221    db  ESC,"*p-36Y.....*c15a50bP"
  323.     db  ESC,"*p+30x+36Y",0
  324. ;  ▐
  325. hpc222    db  ESC,"*p+15x-36Y.*c15a50bP"
  326.     db  ESC,"*p+15x+36Y",0
  327. ;  ▀
  328. hpc223    db  ESC,"*p-11Y.....*c30a25bP"
  329.     db  ESC,"*p+30x+11Y",0
  330.  
  331. ;  Positioning for bold face
  332.  
  333. b_1    db  ESC,"*p-29x-1Y",0
  334. b_2    db  ESC,"*p-1x+1Y",0
  335.  
  336.  
  337. ;************************************************************************
  338. ;************** START OF HPFilter Code **********************************
  339. ;************************************************************************
  340.  
  341.  
  342. MAIN    proc    far
  343.  
  344. HANDLER:    jmp    short HANDLEGO ; skip data
  345.  
  346. INSTALLED    dw    SIGNATURE
  347. ACTIVE        db    1           ; we are active
  348.  
  349. HANDLEGO:
  350.     mov    cs:IN_CHAR,ax           ; save incoming character
  351.  
  352.  
  353. ;  Check for valid situation
  354. ;
  355. ;    not  active ?
  356.  
  357.     cmp    cs:ACTIVE, 1           ; are
  358.     jne    PASSIT               ; we're not running
  359.                        ; runing
  360. ;    not print request ?
  361.  
  362. NXT_T:    or    ah, ah
  363.     je    PROC_IT            ; a print call
  364.  
  365. PASSIT:
  366.        pushf
  367.        call    cs:BIOS_HANDLER
  368.        iret
  369.  
  370. ;*****************************************************************************
  371. ;*****************************************************************************
  372. ;  Now looking at all characters for the HPlj control strings
  373. ;  and my own bold string control
  374. PROC_IT:
  375.        push    di
  376.  
  377. ;---------------------------------------------------------------------------
  378. ;  Did we find an ESCAPE ?
  379.  
  380. CK_ESC:
  381.        cmp     al,ESC               ;is it an ESC
  382.        jne     CHK_CS               ;no
  383.        mov     cs:C_STRING,1           ;start control string
  384.        jmp     EXIT_POP            ;no more processing
  385.  
  386. ;---------------------------------------------------------------------------
  387. ;  Now check if we are in a Control_STRING
  388.  
  389. CHK_CS:
  390.        cmp     cs:C_STRING,1           ; immed after ESC ?
  391.        jl      NO_CS               ; C_STRING = 0 --not in a control string
  392.        jg      LG_CS               ; C_STRING > 1
  393.  
  394. ;  in control string after ESC
  395.        cmp     al,"G"                  ; Is it capital G ?
  396.        jne     CHK_H               ; no - check for 'off' code
  397.        mov     cs:BOLD_ON,1
  398.        mov     cs:C_STRING,0
  399.        jmp     EXIT_POP
  400.  
  401. CHK_H: cmp     al,"H"
  402.        jne     PRT_ESC               ;no - print the stored ESC
  403.        mov     cs:BOLD_ON,0           ;yes - BOLDING off
  404.        mov     cs:C_STRING,0
  405.        jmp     EXIT_POP
  406.  
  407. ;---------------------------------------------------------------------------
  408. ;  Print the stacked ESC and procees
  409.  
  410. PRT_ESC:
  411.        mov     ax,ESC               ; print escape
  412.        pushf                   ; place flags on stack
  413.        call    cs:BIOS_HANDLER           ; an interrupt handler
  414.        mov     ax,cs:IN_CHAR           ; print character
  415.  
  416. ;
  417. ;  Now increment the C_STRING count
  418. ;  check for the end of the control strings
  419.  
  420. LG_CS:
  421.        inc     cs:C_STRING
  422.  
  423. ;  Is it a Capital letter ?
  424.        cmp     al,41h               ;'A'
  425.        jl      NO_CS
  426.        cmp     al,5Ah               ;'Z'
  427.        jg      NO_CS
  428. ;
  429. ;  This is a capital letter
  430.        mov     cs:C_STRING,0;           ; C_STRING=0 = off
  431.  
  432. NO_CS:
  433.  
  434. ;  is the character a line grawing graphic
  435.  
  436.     cmp    al, 179            ; below line drawing
  437.     jl    EXIT_PRNT           ; not a graphics char
  438.     cmp    al, 223            ; above line drawing
  439.     jg    EXIT_PRNT           ; not a graphics char
  440.  
  441. ;==========================================================================
  442. ; we will process this one, save what we will need.
  443.  
  444.  
  445.        sub     ah,ah               ; zero high portion
  446.        sub     al,179               ; adjust number down to 179 base
  447.        shl     ax,1               ; left shift 1 = *2
  448.        add     ax, offset HP_BASE      ; al = base + offet = pointer to string
  449.        mov     di,ax               ; prepare to load pointer address
  450.        mov     di,cs:[di]           ; load pointer address
  451. SLOOP1:
  452.        mov     ah, 0               ;request print
  453.        mov     al,byte ptr cs:[di]     ; load a character
  454.        cmp     al,0               ; is the char zero ?
  455.        je      EXIT_SLOOP           ; end of string
  456.        cmp     al,'.'                  ; spaceing character
  457.        je      SLINC               ; skip it
  458.        pushf                   ; place flags on stack
  459.        call    cs:BIOS_HANDLER           ; an interrupt handler
  460. SLINC: inc     di               ; next character
  461.        jmp     sloop1
  462.  
  463. EXIT_SLOOP:
  464.        jmp     EXIT_POP
  465.  
  466. ; Substitution string has been sent.
  467. ;----------------------------------------------------------------------------
  468. ;  Exit and print the character
  469.  
  470. EXIT_PRNT:
  471. ;  Is BOLDING ON ?
  472.        cmp     cs:BOLD_ON,1
  473.        jne     PRINTIT               ; NO !
  474.  
  475. ;  YES - print the character
  476.  
  477.        mov     ax,cs:IN_CHAR           ;get the character
  478.        pushf
  479.        call    cs:BIOS_HANDLER           ;print it
  480.  
  481. ;  backup the cursor to +1x +1y for the past character printed
  482.  
  483.        mov     ax, offset b_1
  484.        mov     di,ax
  485. SLOOP2:
  486.        mov     ah, 0               ;request print
  487.        mov     al,byte ptr cs:[di]     ; load a character
  488.        cmp     al,0               ; is the char zero ?
  489.        je      EXIT_SLOOP2           ; end of string
  490.        pushf                   ; place flags on stack
  491.        call    cs:BIOS_HANDLER           ; an interrupt handler
  492.        inc     di               ; next character
  493.        jmp     sloop2
  494.  
  495. EXIT_SLOOP2:
  496.  
  497. ;  print the character again
  498.  
  499.        mov     ax,cs:IN_CHAR           ;get the character
  500.        pushf
  501.        call    cs:BIOS_HANDLER           ;print it
  502.  
  503. ;  move cursor back to old position at end of single print
  504.  
  505.        mov     ax, offset b_2
  506.        mov     di,ax
  507. SLOOP3:
  508.        mov     ah, 0               ;request print
  509.        mov     al,byte ptr cs:[di]     ; load a character
  510.        cmp     al,0               ; is the char zero ?
  511.        je      EXIT_SLOOP3           ; end of string
  512.        pushf                   ; place flags on stack
  513.        call    cs:BIOS_HANDLER           ; an interrupt handler
  514.        inc     di               ; next character
  515.        jmp     sloop3
  516.  
  517. EXIT_SLOOP3:
  518.        jmp     EXIT_POP
  519. ;-------------------------------------------------------------------------
  520.  
  521. PRINTIT:
  522.     pushf                ; for iret satisfaction
  523.     call    cs:BIOS_HANDLER     ; an interrupt handler
  524. EXIT_POP:
  525.     pop    di
  526.     iret                ; and return to caller
  527.  
  528. ;---------------------------------------------------------------------------
  529. END_CODE equ     this byte             ; last part of resident
  530.  
  531.  
  532.  
  533. ;************************************************************************
  534. ;        TRANSIENT PART
  535. ;************************************************************************
  536.  
  537. START:    push    ds
  538.     xor    ax, ax
  539.     push    ax                ; .COM programs start like this
  540.  
  541.     mov    es, ax
  542.     mov    si, PRINTER_INTERRUPT*4     ; point to installed address
  543.  
  544.     lods    word ptr es:[si]
  545.     mov    word ptr BIOS_HANDLER, ax
  546.     lods    word ptr es:[si]
  547.     mov    word ptr BIOS_HANDLER+2, ax
  548.  
  549.  
  550.     les    si, BIOS_HANDLER
  551.  
  552.     cmp    word ptr es:[si+2], SIGNATURE    ; this us?
  553.     jne    INSTALL             ; not yet-- install us
  554.  
  555. ; it is us, flop setting of active flag
  556.     mov    al, es:[si+4]            ; pick up running flag
  557.     xor    al, 1                ; flip the bit
  558.     mov    es:[si+4], al            ; replace it
  559.  
  560.  
  561.     mov    dx, offset m$RUNNING        ; for now, assume it's running
  562.     cmp    al, 1                ; were we right?
  563.     jz    MSG_N_SPLIT            ; yes, take this
  564.     mov    dx, offset m$OFFNOW        ; report "off"
  565.  
  566. ; When we get here, DX is pointing to a status message.   Print it and
  567. ;  leave.
  568.  
  569. MSG_N_SPLIT:    DOS    PRINT_MESSAGE        ; "print message" function
  570.     ret                    ; goodbye!
  571.  
  572. ; If we get to this spot, it's the first time that the program has been
  573. ;  run.  Install our own handler into the interrupt vector, report this
  574. ;  event with a message, and let DOS know we want to stay around.
  575.  
  576. INSTALL:
  577.  
  578.     mov    al, PRINTER_INTERRUPT    ; printer interrupt, please
  579.     DOS    SET_VECTOR HANDLER    ; DOS function 25h is "set interrupt"
  580.  
  581.     DOS    PRINT_MESSAGE m$NOWREADY
  582.  
  583. ; Everything's complete.  Leave the program via INT 27H with DX pointing to
  584. ;  the end of the resident part, and DOS'll keep the important stuff around
  585. ;  while freeing up the memory occupied by the part that's not part of
  586. ;  the interrupt handler per se.
  587.  
  588.     mov    dx, offset END_CODE+1    ; point to the end of the fixed part
  589.     int    27H            ; end-but-stick-around
  590.  
  591.  
  592. ; Three status report messages.
  593.  
  594. m$NOWREADY    db    "HPFilter (BOLD & Lite lines) installed and running.$"
  595. m$RUNNING    db    "HPFilter reactivated.$"
  596. m$OFFNOW    db    "HPFilter temporarily deactivated.$"
  597.  
  598. MAIN    endp
  599.  
  600. CSEG    ends
  601.     end    HOME
  602.